import {getToday} from "../../../utils/date";
import {isImage} from "../../../utils/dom";

export function uploadImage(files) {
    /*
    * 1.判断文件类型
    * 2.判断名字*/
    var localFile = files[0];
    if (isImage(localFile)) {
        var name = getToday() + "/" + files[0].name
        var file = new AV.File(name, localFile);
        // console.log(file.url());
        return file.save()
    } else {
        return Promise.reject({message: 'file is not the image '})
    }
}